/*

    This file is part of Blue Violin.

    Blue Violin is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Blue Violin is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero Public License for more details.

    You should have received a copy of the GNU Affero Public License
    along with Blue Violin.  If not, see <http://www.gnu.org/licenses/>.

    Blue Violin  Copyright (C) 2008  Blue Violin, Inc. & Josh Watts <josh.watts@blueviolin.org>
	For more information, visit http://www.blueviolin.org/

    This program comes with ABSOLUTELY NO WARRANTY.

*/

function CreateProfile()
{
}


CreateProfile.prototype.save = function()
{
	var sProfileName = $get("txtProfileName").value;
	var sDefaultUrl = $get("txtDefaultUrl").value;
	var bEmail = $get("checkEmailOnlyOnFail").checked;
	
	if ("" == sProfileName)
	{
		alert("Please enter a Profile Name");
		return;
	}
	
	window.dialogArguments.name = sProfileName;
	window.dialogArguments.defaultUrl = sDefaultUrl;
	window.dialogArguments.emailOnlyOnFail = bEmail;
	
	window.close();
};


CreateProfile.prototype.cancel = function()
{
	window.dialogArguments.name = null;
	window.dialogArguments.defaultUrl = null;
	window.dialogArguments.emailOnlyOnFail = null;
	window.close();
};


CreateProfile.prototype.keyPress = function()
{
	if (27 == window.event.keyCode)
	{
		this.cancel();
	}
	
};


var oCreateProfile = new CreateProfile();


function CreateProfileBodyLoad()
{

	document.body.attachEvent("onkeypress",
							  $createDelegate(oCreateProfile, oCreateProfile.keyPress));
	

	$get("btnSave").attachEvent("onclick",
								$createDelegate(oCreateProfile, oCreateProfile.save));
	$get("btnCancel").attachEvent("onclick",
								   $createDelegate(oCreateProfile, oCreateProfile.cancel));
}
